<template>
	<view class="">
		<view class="topbox">
			<view class="top">
				<image src="https://fangguaner.wm76.mtnet.ren/static/applet/sousuo.png" mode=""></image>
				<input type="text" value=""  placeholder="请输入小区名" @input="plotname"/>
			</view>
		</view>
		<view class="Securitymanagement">
			<view class="cu-list menu sm-border card-menu margin-top">
				<view class="cu-item arrow" v-for="(item,index) in arr" :key="index" @click="returnupload(item.name,item.id)">
					<view class="content">
						<text class="text-grey">{{item.name}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {gethousing} from "../../api/api/index.js"
	export default {
		data() {
			return {
				arr: [],
				type:"",
				time:0,
				page:0,
				limit:20,
				arr1:[],
			};
		},
		methods: {
			plotname(e){
				let data= {keywords:e.detail.value}
				if(e.detail.value==""){
					this.arr=[]
					return
				}else{
					this.time=new Date().getTime()
					let that=this
					setTimeout(()=>{
						if(new Date().getTime()-that.time>499){
							gethousing(data).then(res=>{
								this.arr=res.data
								// that.arr1=res.data
								// this.arr = [...this.arr, ...this.jisuan()]
							})
						}
					},500)
				}
			},
			jisuan(){
				this.page ++
				let pass = []
				let star=(this.page - 1) * 20
				let end = this.page * 20 - 1
				this.arr1.forEach((v,i)=>{
					if(i >= star && i <= end){
						pass.push(v)
					}
				})
				return pass
			},
			returnupload(item,id){
				this.$store.state.text = this.type
				this.$store.state.name =item
				this.$store.state.community_id=id
				uni.navigateBack({
					delta:1
				})
			
			}
		},
		onLoad(e) {
			this.type=e.type
			
		},
		onReachBottom(){
			this.arr = [...this.arr, ...this.jisuan()]
		}
	}
</script>

<style scoped lang="scss">
	.topbox{
		padding: 30rpx;
		box-sizing: border-box;
		.top{
			display: flex;
			align-items: center;
			height: 80rpx;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			border: solid 2rpx #dfdfdf;
			padding-left: 20rpx;
			padding-right: 20rpx;
			box-sizing: border-box;
			image{
				width: 35rpx;
				height: 35rpx;
			}
			input{
				margin-left: 34rpx;
				width:100%;
			}
		}
	}
	.text-grey {
		font-family: MicrosoftYaHei;
		line-height: 48rpx;
		letter-spacing: 0rpx;
		color: #000000 !important;
	}
</style>
